package com.labyrinth.core;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Mesh;
import com.badlogic.gdx.graphics.VertexAttribute;
import com.badlogic.gdx.graphics.VertexAttributes.Usage;

public class Exit extends GameObject
{
    public Exit()
    {
    }

    public Exit(float x, float y, float height, float width)
    {
        super(x, y);
        this.setScale(width, height);
        setTexture("data/door.jpg");
        setDrawType(GL10.GL_TRIANGLE_STRIP);
        setMesh();
    }

    public void setMesh()
    {
        mesh = new Mesh(true, 4, 4, new VertexAttribute(Usage.Position, 3, "a_position"), new VertexAttribute(Usage.TextureCoordinates, 2, "a_texCoord"));
        mesh.setVertices(new float[] { -0.5f, -0.5f, 0, 0, 1, 0.5f, -0.5f, 0, 1, 1, -0.5f, 0.5f, 0, 0, 0, 0.5f, 0.5f, 0, 1, 0 });
        mesh.setIndices(new short[] { 0, 1, 2, 3 });
        vertexCount = 4;
    }

   

    @Override
    public void draw()
    {
        Gdx.gl10.glPushMatrix();
        Gdx.gl10.glTranslatef(position.getX(), position.getY(), 0);
        Gdx.gl10.glScalef(scaleX, scaleY, 0);
        Gdx.graphics.getGL10().glEnable(GL10.GL_TEXTURE_2D);
        texture.bind();
        mesh.render(drawType, 0, vertexCount);
        Gdx.gl10.glPopMatrix();
    }
}
